package edu.ufop.vaadin.jdbc.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import edu.ufop.vaadin.jdbc.ConnectionFactory;
import edu.ufop.vaadin.disciplina.Disciplina;

public class DisciplinaDao {
	private Connection connection;

	public DisciplinaDao() throws Exception{
		this.connection = new ConnectionFactory().getConnection();
	}
	
	public void adiciona(Disciplina disciplina){
		String sql = "insert into disciplina" + "(codigo,nome,ementa)" + " values (?,?,?)";
		
		try{
			PreparedStatement stmt = connection.prepareStatement(sql);
			stmt.setInt(1, disciplina.getCodigo());
			stmt.setString(2, disciplina.getNome());
			stmt.setString(3, disciplina.getEmenta());
			
			stmt.execute();
			stmt.close();
			
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
		
		
	}
	public Disciplina pesquisa (Disciplina disciplina){
		
		
		return disciplina;
		
		
	}
		

}
